#include <iostream>
#include <ctime>
#include <cstring>
#include <unistd.h>
#include "threadPool.hpp"
#include "Task.hpp"

const char *option = "+-*/%";
int main()
{
  // std::cout << "this is main thread" << std::endl;
  // ThreadPool<Task> *tp = new ThreadPool<Task>();
  // tp->start();

  std::cout << "main thread is started" << std::endl;
  sleep(3);
  ThreadPool<Task>::GetIntance()->start();
  srand(time(nullptr));
  while (true)
  {
    // 创建任务
    int data1 = rand() % 10 + 1;
    usleep(100);
    int data2 = rand() % 5;

    char op = option[rand() % strlen(option)];

    Task t(data1, data2, op);

    // int data = rand() % 10 + 1;

    // 交给线程池
    // tp->push(t);
    ThreadPool<Task>::GetIntance()->push(t);
    sleep(1);
  }

  return 0;
}